﻿/***************************************************************************
 *		ElGee Google Chart API Helper
 *		Copyright(C) 2011 by Laurent Geffroy lgeffroy@gmail.com
 * 
 *		This program is free software; you can redistribute it and/or 
 *		modify it under the terms of the GNU General Public License as
 *		published by the Free Software Foundation; either version 2 of 
 *		the License, or (at your option) any later version.
 *		
 *		This program is distributed WITHOUT ANY WARRANTY; without even the
 *		implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
 *		See the GNU General Public License for more details.
 *	
 *      For particular licensing, please contact me at lgeffroy@gmail.com
 *****************************************************************************/


using System;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;

namespace ElGee.Google.Charts
{
    /// <summary>
    /// Chart DataSource Class
    /// </summary>
    [DataContract]
    public class ChartDataSource
    {
        /// <summary>
        /// Gets or sets the tables.
        /// </summary>
        /// <value>The tables.</value>
        [DataMember]
        public Collection<ChartDataTable> Tables { get; private set; }


        /// <summary>
        /// Gets the items count.
        /// </summary>
        /// <value>The items count.</value>
        [DataMember]
        public Int32 ItemsCount
        {
            get
            {
                Int32 items = 0;
                if ((Tables == null) || (Tables.Count == 0))
                    return items;

                for (int i = 0; i < Tables.Count; i++)
                {
                    if ((Tables[i].Data != null) && (Tables[i].Data.Count > 0))
                    {
                        if (Tables[i].Data.Count > items)
                            items = Tables[i].Data.Count;
                    }
                }
                return items;
            }
            private set{}
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="ChartDataSource"/> class.
        /// </summary>
        public ChartDataSource()
        {
            Tables = new Collection<ChartDataTable>();
        }
    }
}
